package com.shanghai.dateselectdialog;

import android.os.Build;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.RequiresApi;
import android.support.v7.app.AppCompatActivity;
import android.widget.Button;
import android.widget.CalendarView;
import android.widget.DatePicker;
import android.widget.TextView;
import android.widget.Toast;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class MainActivity extends AppCompatActivity {

    @BindView(R.id.show_result)
    TextView showResult;
    @BindView(R.id.select_data)
    Button selectData;


    @RequiresApi(api = Build.VERSION_CODES.O)
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        DatePicker datePicker=(DatePicker)findViewById(R.id.datePicker) ;
        datePicker.getCalendarView().setOnDateChangeListener(new CalendarView.OnDateChangeListener() {
            @Override
            public void onSelectedDayChange(@NonNull CalendarView calendarView, int i, int i1, int i2) {
                Toast.makeText(MainActivity.this, ""+i+"-"+i1+"-"+i2, Toast.LENGTH_SHORT).show();

            }
        });
        ButterKnife.bind(this);
        showDiolg("6666");
        DateSelectDialog.setmSelectDateListener(new DateSelectDialog.SelectDateListener() {
            @Override
            public void getBack(boolean flag) {
                Toast.makeText(MainActivity.this, "" + flag, Toast.LENGTH_SHORT).show();
            }
        });

    }

    private void showDiolg(String commandName) {
        DateSelectDialog dateSelectDialog = new DateSelectDialog();
        dateSelectDialog.setCommandName(commandName);
        dateSelectDialog.show(getSupportFragmentManager(), "");
    }

    @OnClick(R.id.select_data)
    public void onViewClicked() {

    }


}
